/**
 * 
 */
package com.dangdang.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dangdang.pojo.ProducePriceChangeEvent;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 *
 * @author ligeng
 * 2019年6月27日
 */
@RestController
public class HelloController {
	 @Autowired
	 private KafkaTemplate<String, String> kafkaTemplate;
	@GetMapping("/")
	public String send() throws JsonProcessingException {
		ProducePriceChangeEvent producePriceChangeEvent = new ProducePriceChangeEvent();
		producePriceChangeEvent.setClientId(1098);
	    ObjectMapper objectMapper = new	ObjectMapper();
		kafkaTemplate.send("subQueue",objectMapper.writeValueAsString(producePriceChangeEvent) );
		return null;
	}
}
